package com.geek.aop.introductions;

import com.geek.aop.config.AopConfig;
import com.geek.aop.introductions.services.MultipleCalculate;
import com.geek.aop.services.CalculateService;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * Aop增强的Introductions学习
 * 主要是这个东西可以为一个类增强方法
 * 比如A类，用Introductions可以为A类添加xx方法，只是使用的时候需要强转类型
 */
public class AopIntroductionsStarter {

    public static void main(String[] args) {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(AopConfig.class);

        CalculateService calculateService = context.getBean(CalculateService.class);
        calculateService.add(1, 2);
        calculateService.sub(1, 2);
        calculateService.multi(1, 2);
        calculateService.div(1, 2);

        MultipleCalculate multipleCalculate = (MultipleCalculate) calculateService;
        String binary = multipleCalculate.toBinary(100);
        System.out.println(binary);
    }

}
